﻿
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using LX.Core;
using System;

namespace S4Store.Domain.SellerCarBrand
{
    public class Row
    {
        public int Id { get; set; }
        public int SellerId { get; set; }
        public int CarBrandId { get; set; }
        public DateTime Month { get; set; }





        [NotMapped]
        [Description("目标首次来店接待批次")]
        [Expression("F/SUM(AH)")]
        public int? C
        {
            get
            {
                return Calculate.Divide(F, Table.Rows.Sum(r => r.AH));
            }
        }

        [Description("月初尚存意向客户数")]
        public int? D { get; set; }

        [Description("首次来店接待批次")]
        public int? E { get; set; }

        [NotMapped]
        [Description("首次来店登记数目标")]
        [Expression("Z/TAB.ULT.AY3")]
        public int? F {
            get
            {
                if (Table.LastMonthData == null)
                {
                    return null;
                }
                return Calculate.Divide(Z, Table.LastMonthData.AvgVr);
            }
        }

        [Description("首次来店客户登记数")]
        public int? G { get; set; }

        [Description("有效A卡建卡数")]
        public int? H { get; set; }

        [Description("试驾邀请书填写数")]
        public int? I { get; set; }

        [Description("试驾客户成交数")]
        public int? J { get; set; }

        [Description("商谈明细表填写数")]
        public int? K { get; set; }

        [Description("超限价格成交数")]
        public int? L { get; set; }

        [Description("当月累计二手车评估数")]
        public int? M { get; set; }

        [Description("当月累计置换成交数")]
        public int? N { get; set; }

        [Description("当月累计按揭成交数")]
        public int? O { get; set; }

        [Description("上月遗留客户新增订单")]
        public int? P { get; set; }

        [Description("当月客户新增订单数")]
        public int? Q { get; set; }

        [Description("当月累计交车数")]
        public int? R { get; set; }

        [Description("新车保险投保数")]
        public int? S { get; set; }

        [Description("当月保险销售总额（万）")]
        public int? T { get; set; }

        [Description("精装套餐车销售数量")]
        public int? U { get; set; }

        [Description("当月装潢销售总额（万）")]
        public int? V { get; set; }

        [Description("当月新车延保数")]
        public int? W { get; set; }

        [Description("二次成功邀约客户数")]
        public int? X { get; set; }

        [Description("当月老客户推荐成交数")]
        public int? Y { get; set; }

        [Description("当月销量目标")]
        public int? Z { get; set; }

        [Description("当日销量完成进度")]
        [NotMapped]
        public int? AA
        {
            get
            {
                return Calculate.Divide((Q + R), Z);
            }
        }

        [Description("当日销量进度差")]
        [NotMapped]
        public int? AB
        {
            get
            {
                return AA-Table.O;
            }
        }

        [Description("来店批次完成进度")]
        [NotMapped]
        public int? AC
        {
            get
            {
                return Calculate.Divide(E, C);
            }
        }

        [Description("来店批次进度差")]
        [NotMapped]
        public int? AD
        {
            get
            {
                return AC-Table.O;
            }
        }

        [Description("当月登记客户完成进度")]
        [NotMapped]
        public int? AE
        {
            get
            {
                return Calculate.Divide(G, F);
            }
        }

        [Description("登记客户进度差率")]
        [NotMapped]
        public int? AF
        {
            get
            {
                return AE-Table.O;
            }
        }

        [Description("当月目标完成率")]
        [NotMapped]
        public int? AG
        {
            get
            {
                return Calculate.Divide(R, Z);
            }
        }

        [Description("首次来店登记率")]
        [NotMapped]
        public int? AH
        {
            get
            {
                return Calculate.Divide(G, E);
            }
        }

        [Description("A卡需求完整分析率")]
        [NotMapped]
        public int? AI
        {
            get
            {
                return Calculate.Divide(H, G);
            }
        }

        [Description("试乘试驾率")]
        [NotMapped]
        public int? AJ
        {
            get
            {
                return Calculate.Divide(I, G);
            }
        }

        [Description("试乘试驾成交率")]
        [NotMapped]
        public int? AK
        {
            get
            {
                return Calculate.Divide(J, I);
            }
        }

        [Description("商谈明细表填写率")]
        [NotMapped]
        public int? AL
        {
            get
            {
                return Calculate.Divide(K, G);
            }
        }

        [Description("上月遗留客户转化率")]
        [NotMapped]
        public int? AM
        {
            get
            {
                return Calculate.Divide(G, E);
            }
        }

        [Description("当月登记客户成交率")]
        [NotMapped]
        public int? AN
        {
            get
            {
                return Calculate.Divide(M, I);
            }
        }

        [Description("订单交车转化率")]
        [NotMapped]
        public int? AO
        {
            get
            {
                return Calculate.Divide(N, J);
            }
        }

        [Description("超限成交率")]
        [NotMapped]
        public int? AP
        {
            get
            {
                return Calculate.Divide(O, K);
            }
        }

        [Description("当月二手车评估率")]
        [NotMapped]
        public int? AQ
        {
            get
            {
                return Calculate.Divide(P, L);
            }
        }

        [Description("当月置换率")]
        [NotMapped]
        public int? AR
        {
            get
            {
                return Calculate.Divide(Q, M);
            }
        }

        [Description("当月保险率")]
        [NotMapped]
        public int? AS
        {
            get
            {
                return Calculate.Divide(R, N);
            }
        }

        [Description("当月按揭成交率")]
        [NotMapped]
        public int? AT
        {
            get
            {
                return Calculate.Divide(S, O);
            }
        }

        [Description("平均单车保险额(万）")]
        [NotMapped]
        public int? AU
        {
            get
            {
                return Calculate.Divide(T, P);
            }
        }

        [Description("精装车销售率")]
        [NotMapped]
        public int? AV
        {
            get
            {
                return Calculate.Divide(U, Q);
            }
        }

        [Description("平均单车装潢额（万）")]
        [NotMapped]
        public int? AW
        {
            get
            {
                return Calculate.Divide(V, R);
            }
        }

        [Description("新车延保实现率")]
        [NotMapped]
        public int? AX
        {
            get
            {
                return Calculate.Divide(W, S);
            }
        }

        [Description("二次邀约成功率")]
        [NotMapped]
        public int? AY
        {
            get
            {
                return Calculate.Divide(X,T);
            }
        }

        [Description("老客户推荐成功率")]
        [NotMapped]
        public int? AZ
        {
            get
            {
                return Calculate.Divide(Y, U);
            }
        }


        public virtual Employee Seller { get; set; }
        public virtual CarBrand CarBrand { get; set; }

        [NotMapped]
        public Table Table { get; set; }
    }
}
